let path = "/user/:user_id/post/:post_id";
let paramNames = [];
let regexpSource = path.replace(/:([^/]+)/g,(_,key)=>{
    paramNames.push(key);
    return `([^\/#\?]+?)`;
});
console.log(regexpSource)
let regexp = new RegExp("^"+regexpSource+"$",'i');
console.log(regexp)
let url = `/user/200/post/2000`;
let result = url.match(regexp);
console.log(paramNames)
console.log(result)